package io.ouka.jvm.hotspot.selfread.read;

import io.ouka.jvm.hotspot.selfread.InstanceKlass;
import io.ouka.jvm.hotspot.selfread.util.FileReader;

import java.io.IOException;

/**
 * @author Ouka
 * ClassLoader
 */
public class ClassLoader {
    private static final MagicReader starterReader = new MagicReader();
    private static final String classPath = "/Users/sizheng/Documents/code/jvm/jvm/target/classes/";

    public static InstanceKlass loadClass(String className) throws IOException {
        String allClassPath = classPath+(className.replaceAll("\\.","/"))+".class";
        byte[] bytes = FileReader.readClass(allClassPath);
        return starterReader.parseContent(bytes);
    }
}
